<?php /*a:1:{s:70:"D:\web\wwwroot\tp5.1\public/../app/admin\view\database\importlist.html";i:1517107122;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表格</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">

<div class="layui-form">
   
    <a  class="layui-btn site-demo-active layui-btn-sm" href="javascript:;" autocomplete="off"> 数据库还原  </a>
    <table class="layui-table">


      <thead>
        <tr>
       
          <th>数据库名称</th>
          <th>卷数</th>
          <th>压缩</th>
          <th>数据大小</th>
          <th>备份时间</th>
          <th>状态</th>
          <th>操作</th>
        </tr> 
      </thead>
    


  <tbody>
    <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): if( count($list)==0 ) : echo "" ;else: foreach($list as $key=>$data): ?>   
       <tr>

          <td><?php echo htmlentities(date('Ymd-His',!is_numeric($data['time'])? strtotime($data['time']) : $data['time'])); ?></td>
          <td><?php echo htmlentities($data['part']); ?></td>
          <td><?php echo htmlentities($data['compress']); ?></td>
          <td><?php echo htmlentities(format_bytes($data['size'])); ?></td>
          <td><?php echo htmlentities($key); ?></td>
          <td class="status">-</td>
          <td class="action">
             <a class="db-down" href="<?php echo url('admin/Database/down',['time'=>$data['time']]); ?>">下载</a>&nbsp;
              <a class="db-import" href="<?php echo url('admin/Database/import',['time'=>$data['time']]); ?>">还原</a>&nbsp;
              <a class="ajax-get confirm" data-href="<?php echo url('admin/Database/delete',['time'=>$data['time']]); ?>">删除</a>
          </td>
        </tr>
    <?php endforeach; endif; else: echo "" ;endif; ?>
      </tbody>
    </table>

  </div>

<script type="text/javascript" src="/static/frame/layui/layui.js"></script>      
<script>
layui.use(['jquery','layer'],function(){
      window.$ = layui.$;
      var layer = layui.layer;


      $(".db-import").click(function(){
            var self = this, status = ".";

            $(this).parent().prevAll('.status').html("").html('等待还原');

            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;
        
            function success(data){

                if(data.code==1){

                    $(self).parent().prev().text(data.msg);

                    if(data.data.part){
                        $.get(self.href, 
                            {"part" : data.data.part, "start" : data.data.start}, 
                            success, 
                            "json"
                        );
                        
                    }  else {
                        layer.alert(data.msg);
                        //window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    layer.alert(data.msg);
                }
            }
        });

          $('.ajax-get').click(function(){
            that = $(this);
                  $.get($(this).attr('data-href'),function(data){
                  if (data.code == 1) {
                      layer.msg(data.msg);
                      that.parents('tr').remove();
                  }
                  });
          })

    //   $(".db-import").click(function(){
    //     // console.log($(this).parents().find(".status").html() );//正常
    //     // console.log($(this).parent().prevAll('.status').html() );
    //     var statusem=$(this).parent().prevAll('.status');
    //     $(this).parent().prevAll('.status').html("").html('等待还原');
    //     thisobj=this;
    //     $.post(this.href, function(data){
         
    //       if(data.code==1){
    //         // statusem.text(""); // 清空数据
    //         // statusem.append('data'); 
    //         // statusem.text("").append('132');
    //         // $(this).parent().prevAll('.status').html("").html(data.msg);//error ：异常原因无法获取当前节点
    //         statusem.html(data.msg);
    //         getdbimport(thisobj,data.data);
    //       }
    //     }, "json");
    //     return false;
    // });
});

</script>


  </body>
</html>